/*
 * spa.util.js
 * root namespace module
 */

/*jslint           browser : true,     continue : true,
   devel : true,    indent : 2,          maxerr : 10,
  newcpa : true,     nomen : true,      plugsplus : true,
  regexp : true,    sloppy : true,
 */

/* global : $,spa */
spa.util = (function($){
    // ------------------------------ BEGIN MODULE SCOPE VARIABLES -----------------------------
    var
       makeError,setConfigModule
    // ------------------------------ END MODULE SCOPE VARIABLES -----------------------------

    // ------------------------------ BEGIN UTILITY METHODS ----------------------------------
    // ------------------------------ BEGIN UTILITY METHODS ----------------------------------

    // ------------------------------ BEGIN DOM METHODS ----------------------------------
    // ------------------------------ END DOM METHODS ----------------------------------

    // ------------------------------ BEGIN EVENT METHODS ----------------------------------
    // ------------------------------ END EVENT METHODS ----------------------------------

    // ------------------------------ BEGIN PUBLIC METHODS ----------------------------------
    // Begin public method /makeError/
    // make an error object including follow properties:
    // msg_name :
    // message :
    // data :

    makeError = function(text,msg,data){
        var
            error = new Error()
        error.text = msg_name
        error.message = msg
        if(data){
            error.data = data
        }
        return error
    }
    // End public method /makeError/

    // Begin public method /setConfigModule/
    //

    setConfigModule = function(arg_map){
        var
            input_map = arg_map.input_map,
            settable_map = arg_map.settable_map,
            config_map = arg_map.config_map,
            key_name,error

        for(key_name in input_map){
            if(input_map.hasOwnProperty()){
                if(settable_map[key_name]){
                    config_map[key_name] = input_map[key_name]
                }
            } else {
                error = makeError('Bad input','['+key_name +'] is not support!')
                throw error
            }
        }
    }
    // End public method /setConfigModule/
    // ------------------------------ END PUBLIC METHODS ----------------------------------

    return {
        makeError : makeError,
        setConfigModule : setConfigModule
    }
}(jQuery))
